package com.example.lib5.search;

public class SeqSearch {
    public static void main(String[] args) {
        int arr[] ={1,9,11,-1,34,89};
        //传入arr与查找值的方法
        int index = seqSearch(arr, -1);
        //获取查找结果，根据结果打印
        if (index==-1) {
            System.out.println("没有找到");
        }else {
            System.out.println(index);
        }

    }

    private static int seqSearch(int[] arr, int value) {
        int index=-1;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i]==value) {
                index=i;
                break;
            }
        }
        return index;
    }
}
